﻿using UnityEngine;
using System.Collections;

public class Chest : MonoBehaviour {
	public bool isChest;
	public bool isKey;

	void OnTriggerEnter2D(Collider2D target){
		if(target.gameObject.tag.Equals("Player")){
		if(isChest){
			Debug.Log("Player Touched Chest");
			if(target.gameObject.GetComponent<PlayerController> ().HasKey){
				Debug.Log("Has a Key");
				target.gameObject.GetComponent<PlayerController> ().HasWildcard = true;
				Debug.Log("Player Got Wildcard");
				target.gameObject.GetComponent<PlayerController> ().HasKey = false;
				Debug.Log("Key is Gone");

			}
		}
		if(isKey){
			target.gameObject.GetComponent<PlayerController> ().HasKey = true;
			Destroy(this.gameObject);
		}
	}
	}
	
}
